package com.jzr.medical.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jzr.common.entity.vo.Result;
import com.jzr.medical.db1.model.TShiftType;
import com.jzr.medical.db1.service.ShiftTypeService;
import com.jzr.medical.db1.vo.ShiftTypeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/shiftType")
public class ShiftTypeController {
    @Autowired
    private ShiftTypeService shiftTypeService;

    @RequestMapping("/codeList")
    public Result<List<TShiftType>> codeList(){
        QueryWrapper<TShiftType> qw = new QueryWrapper<>();
        qw.select("id,code,name1,name2,bg_color,font_color");
        qw.orderByAsc("name1");
        List<TShiftType> list = shiftTypeService.list(qw);
        return Result.success("成功",list);
    }

    @RequestMapping("/list")
    public Result<List<ShiftTypeVo>> list(){
        QueryWrapper<ShiftTypeVo> qw = new QueryWrapper<>();
        List<ShiftTypeVo> list = shiftTypeService.list(qw);
        return Result.success("成功",list);
    }

    @PostMapping("/saveBatch")
    public Result<List<ShiftTypeVo>> saveBatch(@RequestBody List<ShiftTypeVo> list){
        List<ShiftTypeVo>  result = shiftTypeService.saveBatch(list);
        return Result.success("成功",result);
    }
}
